package graphSample;

import java.util.HashMap;

import core.Entity;
import core.Graph;
import core.Process;

public class CycleGraph {
	static public Graph getGraph(){
		Graph g = new Graph("CycleGraph");
		
		// Entities
		Entity e1 = new Entity(g, "State1");
		e1.addVariable("$x","INT");
		
		Entity e2 = new Entity(g, "State2");
		e2.addVariable("$y","INT");
		
		Entity e3 = new Entity(g, "State3");
		e3.addVariable("$u","INT");
		
		Entity e4 = new Entity(g, "State4");
		e4.addVariable("$v","INT");
		
		// Processes
		Process p1 = new Process(g, "Process1", "TRUE");
		p1.addEntityIn(e1); 
		p1.addEntityOut(e2);
		p1.addEvalItem("$y=$x");
		
		Process p2 = new Process(g, "Process2", "TRUE");
		p2.addEntityIn(e2);
		p2.addEntityOut(e3);
		p2.addEvalItem("$u=$y");
		
		Process p3 = new Process(g, "Process3", "TRUE");
		p3.addEntityIn(e3);
		p3.addEntityOut(e4);
		p3.addEvalItem("$v=$u");
		
		Process p4 = new Process(g, "Process4", "TRUE");
		p4.addEntityIn(e4);
		p4.addEntityOut(e1);
		p4.addEvalItem("$x=$v+1");
		
		//Add token in e1
		HashMap<String,String> token;
		for(int i=0;i<2000;i++){
			token = new HashMap<String,String>();
			token.put("$x", String.valueOf(i));
			e1.addToken(token);
		}
		
		return g;
	}
}
